package com.lupan.guice.bindings.constructorBindings;

import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.name.Names;
import com.lupan.guice.bindings.*;
import com.lupan.guice.bindings.instanceBinding.BillingService3;

/**
 * 说明:
 *
 * @author lupan
 * @version 2016/9/27 0027 下午 9:56
 */
public class Main {
    public static void main(String[] args) {
        Injector injector = Guice.createInjector(new AbstractModule() {
            @Override
            protected void configure() {
                try {
                    bind(TransactionLog.class).toConstructor(DatabaseTransactionLog.class.getConstructor());
                    bind(CreditCardProcessor.class).to(PaypalCreditCardProcessor.class);
                } catch (NoSuchMethodException e) {
                    e.printStackTrace();
                }
            }
        });

        BillingService billingService = injector.getInstance(BillingService.class);

        System.out.println(billingService.getLog().log());
    }
}
